<?php
namespace api\bdd\table;

abstract class table {

	private $prepareList = array();

	final public function loadById($query,$id,$handler) {

		
		if( !in_array($query , $this->prepareList )) {
			$prepareList[$query] = $handler->handle()->prepare($this->query($query));
		}
		
		$prepareList[$query]->execute(array($id));
		
		return $prepareList[$query];

	}
	
	final public function query($requete) {
	
		$class = new \ReflectionClass($this);
		
		if($class->hasProperty ($requete)) {
			return $class->getProperty($requete)->getValue();
		} else {
			trigger_error("Call to undefined property ". $class ."::$requete", E_USER_ERROR);
		}
	}
}